package com.suke.czx.modules.examstack.controller;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import com.suke.czx.modules.examstack.entity.Exam2PaperEntity;
import com.suke.czx.modules.examstack.service.Exam2PaperService;
import com.suke.czx.common.utils.PageUtils;
import com.suke.czx.common.utils.Query;
import com.suke.czx.common.utils.R;




/**
 * 
 * 
 * @author Larry
 * @email lawhw@163.com
 * @date 2018-11-01 23:17:48
 */
@RestController
@RequestMapping("/exam/exam2paper")
public class Exam2PaperController {
    @Autowired
    private Exam2PaperService exam2PaperService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("exam:exam2paper:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<Exam2PaperEntity> exam2PaperList = exam2PaperService.queryList(query);
        int total = exam2PaperService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(exam2PaperList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{examId}")
    @RequiresPermissions("exam:exam2paper:info")
    public R info(@PathVariable("examId") Integer examId){
			Exam2PaperEntity exam2Paper = exam2PaperService.queryObject(examId);

        return R.ok().put("exam2Paper", exam2Paper);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("exam:exam2paper:save")
    public R save(@RequestBody Exam2PaperEntity exam2Paper){
			exam2PaperService.save(exam2Paper);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("exam:exam2paper:update")
    public R update(@RequestBody Exam2PaperEntity exam2Paper){
			exam2PaperService.update(exam2Paper);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("exam:exam2paper:delete")
    public R delete(@RequestBody Integer[] examIds){
			exam2PaperService.deleteBatch(examIds);

        return R.ok();
    }
	
}
